#ifndef EGG_RENDERTEXTURE_H
#define EGG_RENDERTEXTURE_H

#include "RenderTarget.h"
#include "Texture2D.h"
#include "DepthBuffer.h"

namespace egg{

    class RenderTexture;
    typedef shared_ptr<RenderTexture> RenderTexturePtr;

    class RenderTexture:public RenderTarget{
    public:
        RenderTexture(uint32 _w,uint32 _h);
        ~RenderTexture();
    public:
        void reserve(uint32 _w,uint32 _h);
        void attachDepth(Texture2DPtr _depth);
        void attachDepth(DepthBufferPtr depth);
        void attachColor(uint32 _slot,Texture2DPtr _color);
        void blitTo(RenderTexturePtr& _dest,bool _depth);

        inline const Texture2DPtr& getColor(uint32 _slot){
            return mColors[_slot];
        }
        inline const DepthBufferPtr& getDepthBuffer(){
            return mDepthBuffer;
        }
        inline const Texture2DPtr& getDepthTexture(){
            return mDepthTexture;
        }
    protected:
        Texture2DPtr mDepthTexture;
        DepthBufferPtr mDepthBuffer;
        map<uint32,Texture2DPtr> mColors;
    };

}

#endif